﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace DragonSolution.Web.Common.Common
{
    public class ConstDim
    {
        //用户Cookie值
        public static readonly string CookieKeyUser = "CurrentUser";

        /// <summary>
        /// 操作成功
        /// </summary>
        public static string operateSuccess = "操作成功";

        /// <summary>
        /// 操作失败
        /// </summary>
        public static string operateFailed = "操作失败";

        /// <summary>
        /// 首页地址
        /// </summary>
        public static string IndexPath
        {
            get
            {
                string path= "/Home/index";
                try
                {
                    return ConfigurationSettings.AppSettings["IndexPath"] ?? path;
                }
                catch (Exception)
                {
                    return path;
                }
            }
        }

        /// <summary>
        /// 后台管理每页数据数量(默认是10)
        /// </summary>
        public static int AdminPageSize {
            get
            {
                try
                {
                    string size = ConfigurationSettings.AppSettings["AdminPageSize"];
                    return string.IsNullOrEmpty(size) ? 10 : Convert.ToInt32(size);
                }
                catch (Exception)
                {
                    return 10;
                }
            }
        }

        /// <summary>
        /// 前台每页数据数量(默认是10)
        /// </summary>
        public static int PageSize
        {
            get
            {
                try
                {
                    string size = ConfigurationSettings.AppSettings["PageSize"];
                    return string.IsNullOrEmpty(size) ? 10 : Convert.ToInt32(size);
                }
                catch (Exception)
                {
                    return 10;
                }
            }
        }

        /// <summary>
        /// 单个产品图片上传个数
        /// </summary>
        public static int ProductMaxCount
        {
            get
            {
                try
                {
                    string size = ConfigurationSettings.AppSettings["ProductMaxCount"];
                    return string.IsNullOrEmpty(size) ? 1 : Convert.ToInt32(size);
                }
                catch (Exception)
                {
                    return 10;
                }
            }
        }

        /// <summary>
        /// 单个产品图片上传最大值（MB）
        /// </summary>
        public static int ProductMaxMB
        {
            get
            {
                try
                {
                    string mb = ConfigurationSettings.AppSettings["ProductMaxMB"];
                    return string.IsNullOrEmpty(mb) ? 10 : Convert.ToInt32(mb);
                }
                catch (Exception)
                {
                    return 10;
                }
            }
        }

        /// <summary>
        /// 产品图片上传格式
        /// </summary>
        public static string ProductExtendName
        {
            get
            {
                string extendName = "jpg,png,gif";
                try
                {
                    return ConfigurationSettings.AppSettings["ProductExtendName"]?? extendName;
                }
                catch (Exception)
                {
                    return extendName;
                }
            }
        }

    }
}
